package com.ljfiction.book.adapter;

import android.graphics.Color;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.R;
import com.ljfiction.book.activitys.ClassfimuchActivity;

import java.util.List;

/**
 * Created by Android on 2017/10/17.
 */

public class TextViewAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private int type = 0;
    private ClassfimuchActivity classfimuchActivity;

    public TextViewAdapter(@LayoutRes int layoutResId, @Nullable List<String> data, int type,ClassfimuchActivity classfimuchActivity) {
        super(layoutResId, data);
        this.type = type;
        this.classfimuchActivity=classfimuchActivity;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        switch (type) {
            case 0://分类按字数
                if (helper.getLayoutPosition() == classfimuchActivity.getNumPosition()) {
                    helper.setTextColor(R.id.totext, Color.parseColor("#f77583"));
                } else {
                    helper.setTextColor(R.id.totext, Color.parseColor("#666666"));
                }
                break;
            case 1://分类按状态
                if (helper.getLayoutPosition() == classfimuchActivity.getZhuangTaiPosition()) {
                    helper.setTextColor(R.id.totext, Color.parseColor("#f77583"));
                } else {
                    helper.setTextColor(R.id.totext, Color.parseColor("#666666"));
                }
                break;

            case 2://分类按时间
                if (helper.getLayoutPosition() == classfimuchActivity.getTimePosition()) {
                    helper.setTextColor(R.id.totext, Color.parseColor("#f77583"));
                } else {
                    helper.setTextColor(R.id.totext, Color.parseColor("#666666"));
                }
                break;
            case 3://分类按分类
                if (helper.getLayoutPosition() ==classfimuchActivity.getRankPosition()) {
                    helper.setTextColor(R.id.totext, Color.parseColor("#f77583"));
                } else {
                    helper.setTextColor(R.id.totext, Color.parseColor("#666666"));
                }
                break;


        }

        helper.setText(R.id.totext, item);
    }


}
